import request from '@/utils/request'
import { tokenName } from '@/config'

export async function login(data) {
  // if (loginRSA) {
  //   data = await encryptedData(data)
  // }
  return request({
    url: '/doLogin',
    method: 'post',
    data,
  })
}

export function logout(accessToken) {
  return request({
    url: '/loginOut',
    method: 'get',
    params: {
      [tokenName]: accessToken,
    },
  })
}

export function getUserInfoByToken(accessToken) {
  return request({
    url: '/sys/sysuser_searchbytoken',
    method: 'get',
    params: {
      [tokenName]: accessToken,
    },
  })
}

export function apply() {
  return request({
    url: '/apply',
    method: 'post',
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post',
  })
}
